#include <allegro5/allegro.h>
#include <allegro5/allegro_primitives.h>  

#include "drawBlock.h"
#include "data_struct_game.h"
#include "blockOperation.h"

/**
 * This function are used for drowing every single square of a block.
 * We use the Allegro function al_draw_filled_rectangle that have these params:
 *  1) initial x position
 *  2) initial y position
 *  3) finishing x position
 *  4) finishing y position
 *  5) color
 * */

void DrawPivot(short int x, short int y, short int r, short int g, short int b){
  al_draw_filled_rectangle(
                (x * 30) + 20, 
                (y * 30) + 50, 
                ((x + 1) * 30) + 20, 
                ((y + 1) * 30) + 50, 
                al_map_rgb(r, g, b));
}

void DrawRight(short int x, short int y, short int r, short int g, short int b){
  al_draw_filled_rectangle(
                ((x + 1) * 30) + 20, 
                (y * 30) + 50, 
                ((x + 2) * 30) + 20, 
                ((y + 1) * 30) + 50, 
                al_map_rgb(r, g, b));
}

void DrawLeft(short int x, short int y, short int r, short int g, short int b){
  al_draw_filled_rectangle(
                ((x - 1) * 30) + 20, 
                (y * 30) + 50, 
                (x * 30) + 20, 
                ((y + 1) * 30) + 50, 
                al_map_rgb(r, g, b));
}

void DrawUp(short int x, short int y, short int r, short int g, short int b){
  al_draw_filled_rectangle(
                (x * 30) + 20, 
                ((y - 1) * 30) + 50, 
                ((x + 1) * 30) + 20, 
                (y * 30) + 50, 
                al_map_rgb(r, g, b));
}

void DrawDown(short int x, short int y, short int r, short int g, short int b){
  al_draw_filled_rectangle(
                (x * 30) + 20,
                ((y + 1) * 30) + 50, 
                ((x + 1) * 30) + 20, 
                ((y + 2) * 30) + 50, 
                al_map_rgb(r, g, b));
}

void DrawUpRight(short int x, short int y, short int r, short int g, short int b){
  al_draw_filled_rectangle(
                ((x + 1) * 30) + 20, 
                ((y - 1) * 30) + 50, 
                ((x + 2) * 30) + 20, 
                (y * 30) + 50, 
                al_map_rgb(r, g, b));
}

void DrawUpLeft(short int x, short int y, short int r, short int g, short int b){
  al_draw_filled_rectangle(
                ((x - 1) * 30) + 20, 
                ((y - 1) * 30) + 50, 
                (x * 30) + 20, 
                (y * 30) + 50, 
                al_map_rgb(r, g, b));
}

void DrawDownRight(short int x, short int y, short int r, short int g, short int b){
  al_draw_filled_rectangle(
                ((x + 1) * 30) + 20, 
                ((y + 1) * 30) + 50, 
                ((x + 2) * 30) + 20, 
                ((y + 2) * 30) + 50, 
                al_map_rgb(r, g, b));
}

void DrawDownLeft(short int x, short int y, short int r, short int g, short int b){
  al_draw_filled_rectangle(
                ((x - 1) * 30) + 20, 
                ((y + 1) * 30) + 50, 
                (x * 30) + 20, 
                ((y + 2) * 30) + 50, 
                al_map_rgb(r, g, b));
}
